<?php

$mid = $_POST['mid'];

include "../../config/database.php";

$con = mysqli_connect($dbhost,$dbuser,$dbpasswd,$dbname);

$sqlname = $dbprefix.'messages';

$sql = "SELECT * FROM `".$sqlname."`";

$i=1;

#echo $sql;

$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
    while($row = mysqli_fetch_assoc($result)) {
        ?>
        <div id="mid-<?php echo $row['id']; ?>">
            <tr>
                <th scope="row"><?php echo $i; ?></th>
                <td><?php
                    if(strlen($row['msg']) >= 35){
                        echo mb_substr($row['msg'] , 0 , 35, 'utf-8').'....';
                    }
                    else echo $row['msg']
                
                ?></td>
                <td>
                    <a class="btn btn-primary" href="../../read/?cid=<?php echo $i ?>" role="button">
                        <i class="nav-icon fas fa-book-open"></i>
                    </a>
                    <botton class="btn btn-primary" role="button" onclick="delcheck(<?php echo $row['id']?>)">
                        <i class="nav-icon fas fa-trash-alt"></i>
                    </botton>
                </td>
            </tr>
        </div>
        <?php
        $i++;
    }
} else {
    $data = array("mid" => $mid);
    $raw = array('code' => 1,"data" => $data);
}

?>

                                        